package com.banyuan;

import java.util.Objects;

/*
* 序列化：把Java对象存储到硬盘上
* 反序列化 ：把硬盘上的文件恢复成对象
* 一个类，要能够序列化，必须实现Serializable接口
* 专门用来做序列化的
*
* */
public class Student implements java.io.Serializable{
    private String name;
    private Integer age;

    private static final long serialVersionUID = -6849794470754997710L;
    public Student() {
    }

    public Student(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Student student = (Student) o;
        return Objects.equals(name, student.name) && Objects.equals(age, student.age);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }
}
